# 给定一个数组 nums，编写一个函数将所有 0 移动到数组的末尾，同时保持非零元素的相对顺序。

class Solution:
    def moveZeroes(self, nums: List[int]) -> None:
        """
        Do not return anything, modify nums in-place instead.
        """
        pos_begin = 0 
        len_list = len(nums)
        if len_list == 1:
            return
        pos_second = 1
        while True:
            if (pos_begin >=  len_list) or (pos_second >= len_list):
                break
            if nums[pos_begin] == 0:
                pos_second = pos_begin + 1
                while pos_second < len_list:
                    if nums[pos_second] != 0:
                        break
                    else:
                        pos_second += 1
                if pos_second < len_list:
                    nums[pos_begin] = nums[pos_second]
                    nums[pos_second] = 0
                    pos_begin += 1
            else:
                pos_begin += 1

 
